import { Component, OnInit } from '@angular/core';

// 引入Onvif相关接口
import {OnvifWsService} from '../onvif-ws.service';

@Component({
  selector: 'app-device-info',
  templateUrl: './device-info.component.html',
  styleUrls: ['./device-info.component.css']
})
export class DeviceInfoComponent implements OnInit {

  // 注入OnvifWsService实例
  constructor(private ws: OnvifWsService) { }

  // 设备信息
  deviceInfo = {
    Model: '',
    Manufacturer: '',
    FirmwareVersion: '',
    SerialNumber: '',
    DiscoveryMode: ''
  };

  ngOnInit() {
    // 获取设备基本信息
    this.ws.getDeviceInformation( info => {

      this.deviceInfo.Model = info['s:Envelope']['s:Body'][0]['tds:GetDeviceInformationResponse'][0]['tds:Model'][0];
      this.deviceInfo.Manufacturer = info['s:Envelope']['s:Body'][0]['tds:GetDeviceInformationResponse'][0]['tds:Manufacturer'][0];
      this.deviceInfo.FirmwareVersion = info['s:Envelope']['s:Body'][0]['tds:GetDeviceInformationResponse'][0]['tds:FirmwareVersion'][0];
      this.deviceInfo.SerialNumber = info['s:Envelope']['s:Body'][0]['tds:GetDeviceInformationResponse'][0]['tds:SerialNumber'][0];
    });

    // 获取设备发现模式
    this.ws.getDiscoveryMode( info => {

      this.deviceInfo.DiscoveryMode = info['s:Envelope']['s:Body'][0]['tds:GetDiscoveryModeResponse'][0]['tds:DiscoveryMode'][0];
    });
  }




}
